module Hello exposing (..)

import Html exposing (text)

type MyList a = 
  Empty | 
  Node a (MyList a)

type Mymaybe a =
  Nothing |
  Just a


fmap_l : (a -> b) -> MyList a -> MyList b
fmap_l f l = 
  case l of
    Empty ->
      Empty

    (Node a rest) ->
      Node (f a) (fmap_l f rest)

fmap_m : (a -> b) -> Mymaybe a -> Mymaybe b
fmap_m f mm =
  case mm of
    Nothing -> 
      Nothing

    (Just a) -> 
      Just (f a)

maybe_list : Mymaybe (MyList number)
maybe_list = Just (Node 1 (Node 2 Empty))

fuck : number -> number
fuck x = x + 1

my_sum : MyList number -> number
my_sum l =
  case l of
    Empty -> 
      0

    Node x rest -> 
      x + (my_sum rest)

main =
    text (toString (fmap_m (fmap_l fuck) maybe_list))